import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class TestOther {
    public static void main(String[] args) {

        Runnable runnable = new Runnable() {
            int count = 1;
            String code;
            public void run() {
               if(count<= 18){
                   if((count&1)!=1){//偶数
                       code = "上";
                       count++;
                   }else{ //奇数
                       code = "OK";
                       count++;
                   }
               }else if(count<36){
                   if((count&1)!=1){//偶数
                       code = "下";
                       count++;
                   }else{ //奇数
                       code = "OK";
                       count++;
                   }
               }else{
                   count =1;
                   return;
               }
                System.out.println(code);
            }
        };
        ScheduledExecutorService service = Executors
                .newSingleThreadScheduledExecutor();
        // 第二个参数为首次执行的延时时间，第三个参数为定时执行的间隔时间
        service.scheduleAtFixedRate(runnable, 1, 1, TimeUnit.SECONDS);
    }
}
